package cn.edu.ecut.se2024.service;

import cn.edu.ecut.se2024.exception.UnauthorizedException;

public class PaymentException {
    
    public void selectPaymentMethod(String method) throws UnauthorizedException {
        if (method == null || method.isEmpty()) {
            throw new UnauthorizedException();
        } else {
            System.out.println("已选择支付方式：" + method);
        }
    }

    public static void main(String[] args) {
        PaymentService paymentService = new PaymentService();
        try {
            paymentService.selectPaymentMethod("Credit Card");
        } catch (UnauthorizedException e) {
            System.out.println("出现支付异常：" + e.getMessage());
            System.out.println("1. 请检查网络连接是否正常。");
            System.out.println("2. 尝试清除浏览器缓存和Cookie，然后重试。");
            System.out.println("3. 如仍然无法解决，请联系客服获取帮助。");
        }
    }
}

